package com.example.softwareconfigurationcoursedesign;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/deleteUser")
public class DeleteUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取要删除的会员的ID
        int userIdToDelete = Integer.parseInt(request.getParameter("userId"));

        // 创建AdminServlet的实例
        AdminServlet adminServlet = new AdminServlet();

        // 调用删除会员的方法
        adminServlet.deleteUserFromDatabase(userIdToDelete);
        System.out.println("删除会员");

        // 重定向到会员列表页面或其他页面
//        response.sendRedirect("<script>window.location.href='Admin.html'</script>");
    }
}